package com.starview.star.operators.system.runtime;

import java.text.DateFormat;
import java.util.Date;

import com.starview.platform.data.EvaluationException;
import com.starview.platform.data.IFunction;
import com.starview.platform.data.IValue;
import com.starview.platform.data.type.IType;
import com.starview.platform.data.type.StandardTypes;
import com.starview.platform.data.type.TypeUtils;
import com.starview.platform.data.value.Factory;
import com.starview.star.operators.CafeEnter;



public class ShowDate implements IFunction
{
  @CafeEnter
  public static String enter(Long timestamp) throws EvaluationException
  {
    DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
    return df.format(new Date(timestamp));
  }

  @Override
  public IValue enter(IValue... args) throws EvaluationException
  {
    return Factory.newString(enter(Factory.lngValue(args[0])));
  }

  @Override
  public IType getType()
  {
    return TypeUtils.functionType(StandardTypes.longType, StandardTypes.stringType);
  }
}
